{% extends "base.html" %}
{% import "_macros.html" as macros %}

{% block title %}Fly - {{ user.username }} {{ title }} {% endblock %}

{% block page_content %}
{% include '_userbase.html' %}
<div class="btn-group">
<a href="{{ url_for('.user',username=user.username)}}" class="btn btn-default" >{{ user.posts.count() }}篇博客</a>
<a href="{{ url_for('.usercomments',username=user.username)}}" class="btn btn-default">{{ user.comments.count() }}条评论</a>
<a href="{{ url_for('.starposts', username=user.username) }}" class="btn btn-info">{{ user.starposts.__len__() }}篇收藏</a>
</div>
</br>

<div class="row">
 <div class="col-xs-12">
<!--   <div class="box"> -->
<!--     <div class="box-header">
      <div class="box-tools">
        <div class="input-group" style="width: 150px;">
          <input type="text" name="table_search" class="form-control input-sm pull-right" placeholder="Search">
          <div class="input-group-btn">
            <button class="btn btn-sm btn-default"><i class="fa fa-search"></i></button>
          </div>
        </div>
      </div>
    </div> --><!-- /.box-header -->
    <div class="box-body table-responsive no-padding">
      <table class="table table-hover">
        <tr>
          <th>作者</th>
          <th>标题</th>
          <th>收藏时间</th>
          <th>操作</th>
          <th>正文</th>
        </tr>
        {% for post in posts %}
        <tr>
          <td><a href="{{ url_for('.user', username=post.author.username) }}">{{ post.author.username }}</a></td>
          <td><a href="{{ url_for('.post', id=post.id) }}">{{ post.head }}</a></td>
          <td>{{ moment(user.startimestamp(post)).format('L') }}</td>
          <td>
          {% if current_user == user %}
          <a href="{{ url_for('.deletestar', id=post.id,) }}" class="label label-danger">
              删除
              </a>
          {% else %}
          <a href="#" class="label label-default">
              无权限
              </a>
          {% endif %}
          </td>
          <td>
          <a style="text-decoration:none; color:black" href="{{ url_for('.post', id=post.id) }}">
            {% if post.body[30] %}
            {{ post.body[0:30] }}....
            {% else %}
            {{ post.body}}
            {% endif %}               
          </a>
          </td>
        </tr>
        {% endfor %}
      </table>
    </div><!-- /.box-body -->
<!--   </div> --><!-- /.box -->
</div>
</div>
{% endblock %}
